package joey.project1.view

import java.awt.Component
import java.awt.Graphics
import java.awt.Image;
import java.net.URL;

import javax.swing.ImageIcon

class SizeImageIcon extends ImageIcon {
	private int height
	private int width

	public SizeImageIcon(String filename, String description){
		super(filename,description)
	}
	public SizeImageIcon (String filename){
		super(filename)
	}
	public SizeImageIcon(URL location, String description){
		super(location,description)
	}
	public SizeImageIcon (URL location){
		super(location)
	}
	public SizeImageIcon(Image image, String description){
		super(image,description)
	}
	public SizeImageIcon (Image image){
		super(image)
	}
	public SizeImageIcon (byte[] imageData, String description){
		super(imageData,description)
	}
	public SizeImageIcon (byte[] imageData){
		super(imageData)
	}
	public SizeImageIcon(){
	}

	@Override
	public void paintIcon( Component c, Graphics g, int x, int y ) {
		if(width <= 0 || height <= 0){
			super.paintIcon(c, g, x, y)
		}else{
			g.drawImage(getImage(), x, y, width, height, c)
		}
	}

	@Override
	public int getIconHeight() {
		if(height <= 0)
			return super.getIconHeight()
		return height
	}

	@Override
	public int getIconWidth() {
		if(width <= 0)
			return super.getIconWidth()
		return width
	}
}
